﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.Xml;
using System.Collections;
using System.Configuration;
using A2DFramework.SQLDispatcherService.Context;
using A2DFramework.SQLDispatcherService.Configuration;

namespace A2DFramework.SQLDispatcherService.SimpleADOdotNetDispatcher
{
    public sealed class SqlHelperCoordinator
    {
        public static int ExecuteNonQuery(CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            string region = SQLDispatcherContext.GetCurrentContext().Region;
            DB db=DBSelector.SelectDB(commandText, region);
            return SqlHelper.ExecuteNonQuery(db.ConnectionString, commandType, commandText, commandParameters);
        }
        public static object ExecuteScalar(CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            string region = SQLDispatcherContext.GetCurrentContext().Region;
            DB db = DBSelector.SelectDB(commandText, region);
            return SqlHelper.ExecuteScalar(db.ConnectionString, commandType, commandText, commandParameters);
        }
        public static SqlDataReader ExecuteReader(CommandType commandType, string commandText, params SqlParameter[] commandParameters)
        {
            string region = SQLDispatcherContext.GetCurrentContext().Region;
            DB db = DBSelector.SelectDB(commandText, region);
            return SqlHelper.ExecuteReader(db.ConnectionString, commandType, commandText, commandParameters);
        }
    }
}